//1137. 第 N 个泰波那契数
//滑动窗口解法

class Solution {
public:
    int tribonacci(int n) {
        if(0 == n) return 0;
        if(n <= 2) return 1;

        int ret = 0;
        int a = 0, b = 1, c = 1;
        for(int i = 3; i <= n; i++)
        {
            ret = a + b + c;
            a = b;
            b = c;
            c = ret;
        }
        return ret;
    }
};